Instruction set for bi-directional conversion and transfer of integer and floating point data

ABSTRACT

An apparatus and method for bi-directional format conversion and transfer of data between integer and floating point registers is provided. A floating point register is configured to store floating point data, and integer data, in a variety of numerical formats. Data is moved in and out of the floating point register as integer data, and is converted into floating point format as needed. Separate processor instructions are provided for format conversion and data transfer to allow conversion and transfer operations to be separated.

CROSS REFERENCE TO RELATED APPLICATIONS

[0001] This application is a Divisional of U.S. Patent Application Ser. No. 08/980481 (Docket CNTR:1395), filed Nov. 29, 1997, entitled “INSTRUCTION SET FOR BIDIRECTIONAL CONVERSION AND TRANSFER OF INTEGER AND FLOATING POINT DATA”.

BACKGROUND OF THE INVENTION

[0002] 1. Field of the Invention

[0003] This invention relates in general to the field of microprocessors, and more particularly to a method and apparatus for converting and transferring data between floating point and integer registers without first storing the data in memory.

[0004] 2. Description of the Related Art

[0005] One of the fundamental applications of a computer system is the processing and storing of numeric data (sometimes called “number crunching”). To more efficiently perform digital operations on numeric data, scientists and engineers have adopted numerical structures that differ from those used in traditional mathematics. First of all, to perform arithmetic operations, a computer must be capable of storing and retrieving numerical data. The numerical data should ideally be stored in consistent formats designed to minimize space and optimize processing efficiency. Historically, numeric data was stored in structures devised to fit the characteristics of a specific machine. Only recently have common standards been adopted that define mathematical standards for digital computers.

[0006] In general, modern computer systems treat numerical data as either integer data or floating point data depending on the application, the size of the number required by the application, and the type of operation to be performed on the data. Because of the difference in data formats between integer data and floating point data, microprocessors typically have two separate processing units, one for processing integer data (the Integer Unit, or IU), the other for processing floating point data (the Floating Point Unit, or FPU). Integer data is operated on by the integer unit within a microprocessor, while floating point data is operated on by the floating point unit within a microprocessor.

[0007] Frequently, data is shared by both an integer unit and a floating point unit. When data is shared, it must first be converted into an acceptable form, depending on whether it will be operated upon by the integer unit or the floating point unit. Conversion of data into an acceptable form is typically accomplished as a single operation that converts the data, from integer to floating point, or from floating point to integer, and then stores the converted data into memory.

[0008] Thus, before an integer unit can operate on data that is in a floating point unit, the data must first be converted into integer format, and then stored to memory. Alternatively, before a floating point unit can operate on data that is in an integer unit, the data must first be converted into floating point format, and then stored to memory. In modern microprocessors, requiring data to be converted, stored to memory, and then retrieved from memory, is very time consuming for the microprocessor, and adds significant delay in processing the data.

[0009] Therefore, what is needed is an apparatus and method that converts numerical data into an acceptable format for either an integer unit, or a floating point unit, without requiring the data to be stored to, and later retrieved from memory. Furthermore, what is needed is a microprocessor that shares data between an integer unit and a floating point unit, and separates the steps of format conversion and data movement.

SUMMARY

[0010] To address the above-detailed deficiencies, it is an object of the present invention to provide a method and apparatus for bi-directional transfer of data between a floating point unit and an integer unit, without requiring intermediate storage in system memory.

[0011] Accordingly, in the attainment of the aforementioned object, it is a feature of the present invention to provide a microprocessor that includes an integer register file, a floating point register file, and a first conversion instruction. The integer register file is configured to store a plurality of integers. The floating point register file is coupled to the integer register file and is configured to store a plurality of floating point numbers. The floating point register file is also configured to store data in integer format. The first conversion instruction is provided by a translator, or by a control ROM. The first conversion instruction converts a first one of the plurality of floating point numbers within the floating point register file into a first integer and temporarily stores the first integer within the floating point register file.

[0012] An advantage of the present invention is that data may be transferred between the integer register file and the floating point register file much faster than the prior art, since the microprocessor does not have to store the converted data in system memory.

[0013] Another object of the present invention is to provide a floating point register file that can store either floating point data or integer data.

[0014] It is therefore a feature of the present invention to provide a floating point register file within a microprocessor. The floating point register file includes a plurality of floating point registers, and conversion logic. The plurality of floating point registers store floating point numbers in extended precision format. The conversion logic is coupled to the plurality of floating point registers and is configured to convert the floating point numbers into integers, and to store the integers into the plurality of floating point registers. Once the conversion is complete, the integer data can be moved to the integer register file.

[0015] An advantage of the present invention is that by allowing the floating point register file to store both floating point data, and integer data, the conversion process can be separated into two distinct steps of converting the data, and moving the data.

[0016] It is therefore an object of the present invention to separate data interchange between the floating point register and the integer register into two distinct steps: converting the data, and moving the data.

[0017] Another feature of the present invention is to provide a method for transferring data between an integer register file and a floating point register file that does not require intermediate storage of the data in system memory. One method includes retrieving integer data from an integer register file and storing the integer data into a floating point register file. This method further includes converting the stored integer data in the floating point register file into floating point data.

[0018] An alternative method includes converting floating point data in a floating point register file into integer data, retrieving the integer data from the floating point register file and storing the integer data into an integer register file. Depending on which method is used, data can either begin as integer data in the integer register, and can be moved to the floating point register and converted. Or, data can begin as floating point data in the floating point register, and can be converted and moved to the integer register.

[0019] An advantage of this invention is that data conversion and movement between an integer unit and a floating point unit can be rapidly performed without requiring intermediate storage in system memory.

[0020] A further advantage of the present invention is that since the steps of conversion and movement are distinct, other instructions may be placed between the steps of conversion and movement, to eliminate dependency stalls in the pipeline of a microprocessor.

BRIEF DESCRIPTION OF THE DRAWINGS

[0021] These and other objects, features, and advantages of the present invention will become better understood with regard to the following description, and accompanying drawings where:

[0022]FIG. 1 is a table illustrating floating point data formats for numerical data.

[0023]FIG. 2 is a block diagram of a portion of a microprocessor that transfers data between floating point and integer register files via memory.

[0024]FIG. 3 is a block diagram of the integer and floating point register files illustrated in FIG. 2.

[0025]FIG. 4 is a table illustrating the data conversion and move instructions according to the present invention.

[0026]FIG. 5 is a portion of the microprocessor according to the present invention for converting and moving data between integer and floating point register files, without requiring intermediate storage in memory.

[0027]FIG. 6 is a flow chart illustrating conversion of floating point data into an integer format, and transfer of the converted data from a floating point register into an integer register.

[0028]FIG. 7 is a flow chart illustrating transfer of integer data from an integer register into a floating point register, and conversion of the integer data into floating point format.

DETAILED DESCRIPTION

[0029] Referring to FIG. 1, a table 100 is provided that illustrates common formats for numerical data within a microprocessor system. The table is divided into two parts, one associated with Binary Integers, the other associated with Binary Real Numbers.

[0030] Integer numbers are typically stored in one of three formats that have identical structure but different capacity. The word integer format occupies two bytes (16-bits), the short integer format takes up a double word (32-bits), and the long integer format a quadword (64-bits). In all three formats the most significant bit encodes the sign of the number. Generally, a sign bit of 1 represents a negative number and a sign bit of 0 a positive number. Positive numbers are stored in pure binary form. Negative numbers are represented as two's complement form.

[0031] The term Real Number, on the other hand, is typically used to designate a number than can be represented in signed, floating point form. Table 100 shows three floating point encodings for binary real numbers. All three real number formats have the following fields: a sign bit field, an exponent field, and a significand field. The sign bit field, which is the most significant bit in the encoding, represents the sign of the number. A 1-bit in the sign field indicates a negative number and a 0-bit indicates a positive number. The exponent field encodes the position of the significand's binary point. The exponent encoding is in bias form. Therefore, if the absolute value of the exponent is less than the bias, then the exponent is negative. This eliminates the need to store the sign of the exponent. An exponent smaller than the bias is in the negative range. An exponent larger than the bias is in the positive range. The exponent is zero if it is equal to the bias. The significand field encodes the number's significant digits as a binary fraction. Normal numbers have an exponent in the range of 11 . . . 10 to 00 . . . 01 and the significand is a binary fraction in the form 1.xx..xx. The number of digits in the fractional part of the significand changes in the different formats. The integer digit of the significand is implicit in the single and double precision formats but is explicitly coded in the extended precision format.

[0032] As mentioned in the Background above, binary integers are operated on by an integer unit, and binary real numbers are operated on by a floating point unit. The integer unit may store data in its integer register file in any of the three integer formats shown in table 100. However, the floating point unit, even though it reads and writes data in any of the three real number formats, always stores data within its floating point register file, in 80-bit extended precision format. Numbers encoded in the remaining formats, typically exist only in memory. Thus, when a number is loaded from memory into a floating point register file, it is automatically converted into the extended precision format.

[0033] With the above overview of numeric formats within computer systems, a more detailed description of the problem to which the present invention is directed will be provided with reference to FIG. 2.

[0034]FIG. 2 contains a portion of a pipeline microprocessor 200. The microprocessor 200 contains an instruction cache 202 for temporarily storing instructions to be executed by the microprocessor. The instructions stored by the instruction cache 202 can be either integer instructions, or floating point instructions. During the Fetch stage of the microprocessor 200, an instruction is fetched from the instruction cache 202 and provided to an instruction buffer 204. The instruction buffer 204 provides temporary storage for one or more instructions that are to be translated and executed by following stages in the pipeline.

[0035] The instruction buffer 204 provides instructions, to a translator 206 during a translate stage of the pipeline.

[0036] The translator 206 translates, or decodes, the integer or floating point instructions into micro operations that can be executed by either an integer unit 208 or a floating point unit 210. If the translated instructions operate on integer data, they are provided to the integer unit 208. If the translated instructions operate on floating point data, they are provided to the floating point unit 210.

[0037] During the Register stage of the pipeline, either the integer unit 208 or the floating point unit 210 retrieves data specified by translated instructions from the IU register file 209 or the FPU register file 211, respectively. The numeric data in the IU register file 209 is stored in 16, 32 or 64-bit integer format. The data stored in the FPU register file is stored in 80-bit extended precision format. The specified data is retrieved from the appropriate register file and is provided to the IU 208 or the FPU 210 for operation. The result of the operation is either stored back into the IU register file 209, via bus 214, or the FPU register file 211, via bus 216, or is written into memory 212. One skilled in the art will appreciate that although portions of the memory 212 may be cached within the microprocessor 200, the memory 212 indicated is external to the microprocessor 200. Thus, when either the IU 208 or the FPU 210 needs to write data to, or read data from the memory 212, the microprocessor 200 delays processing until the memory 212 can respond.

[0038] In the prior art, if data resides in the FPU register file 211 (in extended precision format), and it is needed by the integer unit 208, a programmer is required to first execute an instruction that converts the data in the FPU register file 211 into the desired integer format, and then stores the converted data into the memory 212.

[0039] Within an x86 microprocessor, the instruction that performs this conversion/move operation is the FIST instruction. The FIST instruction converts the value stored in a floating point register ST into a signed integer according to the rounding control specified in a floating point control word. The FIST instruction then transfers the result to a memory destination in the memory 212 that is specified by the instruction. The FIST instruction, within the Pentium microprocessor manufactured by Intel Corporation, requires 6 clock cycles to perform the conversion and transfer. After the data is stored into the memory 212, if it is desired by the integer unit 208, it is then retrieved from the memory 212. An instruction that performs the retrieval is the MOV instruction. The MOV instruction retrieves the converted data and stores it into the IU register file 209. As mentioned above, the process of storing the converted data into the memory 212, and then retrieving the data from the memory 212 adds significant delay in processing the data. In the case of the Pentium microprocessor, at least 7 clock cycles are required to convert and move a single datum from the FPU register file 211 to the IU register file 209.

[0040] Alternatively, if the FPU 210 requires data that is in the IU register file 209, a programmer must first execute an instruction that moves the integer data from the IU register file 209 to the memory 212. This instruction is the MOV instruction, and typically requires a single clock cycle. The programmer must then execute an instruction that retrieves the data from the memory 212, and converts the data to the correct floating point format, before storing the data into the FPU register file 211. An instruction for performing the retrieval and conversion is FILD. This instruction converts the source operand in the memory 212 into extended precision floating point format, and pushes it into the FPU register file 211. The FILD instruction typically requires 3 clock cycles. So, if the FPU register file 211 requires a single datum from the IU register file 209, at least 4 clock cycles are required.

[0041] Both of the above scenarios presume that the microprocessor 200 can access the memory 212 immediately. It is possible, however, in a multi-master environment that the microprocessor 200 may have to wait longer than is specified above to access the memory 212, thus adding further delay to the process. Moreover, if multiple pieces of data are required to be shifted between the IU register file 209 and the FPU register file 211, the problem of delay is exacerbated.

[0042] Now referring to FIG. 3, a portion of a microprocessor 300, according to the present invention is provided. Specifically, the portions that are shown are an integer register file 309 and a floating point register file 311. The integer register file 309 contains a plurality of 32-bit registers for storing either 16 or 32-bit integers. The floating point register file 311 contains a plurality of 80-bit registers for storing floating point data in extended precision format. In addition, the floating point register file 311 is configured to allow 16, 32 or 64 bit integers to be stored. In one embodiment, the 16, 32 or 64 bit integers are stored into bits 0-63, typically associated with the significand. With the floating point register 311 configured to store integer values, the floating point register 311 can be used as intermediate storage of data between the integer register file 309 and the floating point register 311, without requiring data to be stored in an external memory. Transfer between the integer register file 309 and the floating point register file 311 is accomplished using a bus 320. One skilled in the art will appreciate that the bus 320 is illustrative only. In a pipeline microprocessor, both the integer register file 309 and the floating point register file 311 have multiple read/write ports that are accessed during a register stage and/or a write back stage.

[0043] Also located within the register file 311 is conversion logic 315. The purpose of the conversion logic 315 is to convert data within the floating point register file 311 into a desired format. The conversion logic 315 can convert extended precision floating point data into 16, 32 or 64 bit integer data, or vice versa. The methods for bi-directionally converting and moving data between the integer register file 309 and the floating point register file 311 will be further described below with reference to FIGS. 6, 7.

[0044] Now referring to FIG. 4, a table 400 is shown illustrating an instruction set according to the present invention for converting data between floating point and integer formats, and for moving data between a floating point register file and an integer register file. The table 400 is separated into conversion instructions and move instructions.

[0045] The Conversion instructions are of two types: 1) Floating point to Integer (FMXCVT_xF); and 2) Integer to Floating Point (FMXCVT_Fx). The FMXCVT_xF instruction converts the contents of a floating point register (in 80-bit extended precision format) into an integer format of either 16, 32 or 64 bit, depending on the form of the instruction, and stores the result back into the floating point register file. The FMXCVT_Fx instruction converts the contents of a floating point register (in 16, 32 or 64-bit format) into extended precision format, and stores the result back into the floating point register file.

[0046] The Move instructions are also of two types: 1) Move from Floating point register file to Integer register file; and 2) Move from Integer register file to Floating point register file. The Floating Point to Integer instructions allow a programmer to specify the form of the data to be moved into the integer register file. For example, if the data to be moved is in 32-bit integer format, a programmer would specify the instruction FMXMOV_IL.

[0047] Alternatively, the Integer to Floating point instructions move the contents of an integer register into a floating point register, according to the format specified by the instruction. For example, if the data to be moved is a 64-bit integer, the programmer would use the FMXMOV_FL instruction. In one embodiment, since the integer register file contains 32-bit registers, a 64-bit move, to or from the integer register file, writes or reads the first 32-bits from the integer register specified by the move instruction, and reads or writes the second 32-bits from the next integer register following that specified by the instruction.

[0048] In view of the above, operation of the present invention will now be described with reference to FIGS. 5-7.

[0049] Referring first to FIG. 5, a portion of a pipeline microprocessor 500, incorporating the present invention, is shown. The microprocessor includes similar stages and elements, as described above with reference to FIG. 2, but incorporates the register files described below with reference to FIG. 3. Like elements have like numbers, with the hundreds digit replaced by 5.

[0050] In operation, if the IU 508 requires data located within the FPU register file 511, a programmer can execute two instructions, according to the formats described above with reference to FIG. 4. The first instruction is of the form FMXCVT_xF to convert the floating point number into an integer, and restore the integer into the FPU register file 511. The second instruction is of the form FMXMOV_lx to move the converted datum to the designated register within the IU register file 509. It should be appreciated that neither of these instructions required the microprocessor 500 to access the memory 512, either to store the converted data, or to retrieve the converted data. Thus, in many instances, the instructions that convert the data and move the data can be performed within a single clock cycle.

[0051] Moreover, since the FPU register file 511 is capable of storing data in integer format, the move instructions and the convert instructions may be separated in time. This allows a programmer to insert other instructions into the pipeline between the move and convert operations, either to prevent stalls associated with interlock dependencies, or to perform multiple moves or conversions, back to back.

[0052] The methodology for allowing the FPU register file 511 to access data in the IU register file 509 is similar to that described above. However, rather than performing the conversion first, a programmer first moves the desired data from the IU register file 509 into the FPU register file 511. The programmer then converts the data into floating point format, according to whether the data moved was in 16, 32 or 64-bit integer format. Again, since the move and convert operations are distinct, they need not follow each other directly. Rather, other instructions can be inserted between the move and convert operations, as described above.

[0053] Now referring to FIG. 6, a flow chart 600 is provided that illustrates the method of the present invention for moving data from a FPU to an IU. The process begins at step 602 and proceeds to step 604.

[0054] At step 604, the data to be moved is converted from extended precision floating point format to the desired integer format, and is stored back into the floating point register file. Flow then proceeds to step 606.

[0055] At step 606, the converted data is moved from the floating point register file into the integer register file, as specified by a move instruction. Flow then proceeds to block 608 where the conversion/move process is complete.

[0056] Referring to FIG. 7, a flow chart 700 is provided that illustrates the method of the present invention for moving data from an IU to a FPU. The process begins at step 702 and proceeds to step 704.

[0057] At step 704, the desired data is moved from the integer register file to the floating point register file. Flow then proceeds to step 706.

[0058] At step 706, the moved data is converted from integer format into extended precision floating point format. As explained above, the data will be converted according to the convert instruction specified by the programmer. After the data is converted, flow proceeds to block 708 where the process is complete.

[0059] Thus, whether data is located within an integer register or a floating point register, or whether the data is in a floating point format or an integer format, the present invention allows a programmer to convert the data into a desired format, and move the data bi-directionally between the integer register file and the floating point register file, without requiring a microprocessor to perform a bus access to external memory.

[0060] Although the present invention and its objects, features, and advantages have been described in detail, other embodiments are encompassed by the invention. For example, the conversion logic described above has been illustrated in connection with the floating point register file. It is possible that the conversion logic could be located either with the integer register file, or in another portion of the microprocessor. Moreover, although the floating point register file has been used to store integer values, this selection was made because the typical size of floating point registers allows storage of 64-bit integers. However, in future processors, it may be desirable to allow data in floating point format to be temporarily stored in the integer register file. Whether the converted data is temporarily stored in the floating point register file, or the integer register file, or whether the conversion logic is coupled to either of the register files, is not of concern. Rather, it is the bi-directional transfer between register files, without requiring access to external memory, and the separation of the conversion and move operations, that provides the advantages of the present invention.

[0061] Those skilled in the art should appreciate that they can readily use the disclosed conception and specific embodiments as a basis for designing or modifying other structures for carrying out the same purposes of the present invention without departing from the spirit and scope of the invention as defined by the appended claims. 

We claim:
 1. A floating point register file within a microprocessor, the floating point register file comprising: a plurality of floating point registers, for storing floating point numbers in extended precision format; and conversion logic, coupled to said plurality of floating point registers, configured to convert said floating point numbers into integers, and to store said integers into said plurality of floating point registers.
 2. The floating point register file as recited in claim 1 wherein said plurality of floating point registers store said integers in either 16, 32 or 64-bit integer format.
 3. The floating point register file as recited in claim 1 wherein said conversion logic retrieves a first one of said floating point numbers from one of said plurality of floating point registers, converts said first one of said floating point numbers into a first integer, and stores said first integer into a second one of said plurality of floating point registers.
 4. The floating point register file as recited in claim 1 wherein said conversion logic retrieves a first integer from a first one of said plurality of floating point registers, converts said first integer into a first floating point number, and stores said first floating point number into a second one of said plurality of floating point registers.
 5. A method for transferring data between an integer register file and a floating point register file, the method comprising: retrieving integer data from an integer register file and storing the integer data into a floating point register file; and converting the stored integer data into floating point data; wherein intermediate storage of the integer data in system memory is not required during retrieval of the integer data.
 6. The method for transferring data as recited in claim 5 wherein the floating point register file comprises a plurality of floating point registers, the plurality of floating point registers for storing data in either floating point format, or integer format.
 7. The method for transferring data as recited in claim 5 wherein during retrieval of the integer data, the integer data is defined in 16, 32 or 64-bit integer format.
 8. The method for transferring data as recited in claim 5 wherein said step of converting specifies whether the integer data to be converted is defined in 16, 32 or 64-bit integer format.
 9. The method for transferring data as recited in claim 5 further comprising: storing the converted floating point data into the floating point register file.
 10. A method for transferring data between a floating point register file and an integer register file, the method comprising: converting floating point data in the floating point register file into integer data; and retrieving the integer data from the floating point register file and storing the integer data into the integer register file; and wherein intermediate storage of the integer data is not required during conversion of the floating point data.
 11. The method for transferring data as recited in claim 10 wherein said step of converting specifies whether the floating point data to be converted is to be converted into 16, 32 or 64-bit integer format.
 12. The method for transferring data as recited in claim 10 wherein said step of retrieving specifies whether the integer data to be stored in the integer register file is in 16, 32 or 64-bit integer format.
 13. The method for transferring data as recited in claim 10 wherein said step of converting further comprises the step of: storing the converted integer data into the floating point register file.
 14. A microprocessor comprising: integer means configured to store a plurality of integer data; floating point means, coupled to said integer means, configured to store a plurality of floating point data and a plurality of integer data; and conversion means, coupled to said floating point means, configured to convert a first one of said floating point data in said floating point means into a first integer, and to store said first integer into said floating point means.
 15. The microprocessor as recited in claim 14 wherein said conversion means is also configured to convert a second integer stored within said floating point means into a second one of said plurality of floating point data, and to store said second one of said plurality of floating point data into said floating point means.
 16. The microprocessor as recited in claim 14 further comprising: transfer means, coupled to said integer means and said floating point means, configured to transfer a first one of said plurality of integer data from said floating point means to said integer means.
 17. The microprocessor as recited in claim 14 further comprising: transfer means, coupled to said integer means and said floating point means, configured to transfer a first one of said plurality of integer data from said integer means to said floating point means.
 18. A microprocessor comprising: an integer register file configured to store a plurality of integers; a floating point register file, coupled to said integer register file, configured to store a plurality of floating point numbers, said floating point register file also configured to store data in integer format; and a first conversion instruction, provided by a translator, for converting a first one of said plurality of floating point numbers within said floating point register file into a first integer, and for temporarily storing said first integer within said floating point register file. 